package mf.words.navigation;

import java.io.File;
import java.io.IOException;
import javax.swing.JFileChooser;

/** 
 * Navigates through the text given by a grammar-based compressed file.
 */
public class wordNavigate {
	
	//help text displayed when you dont specify a file to rePair
	private final static String helpText = 
		"Usage: wordNavigate [debug]\n"+
	    "Add debug as parameter to show additional debugging information.\n";
	
	//debug mode displays more informations
	private static boolean DEBUG_MODE = false;

	/** Starts the program. */
	public static void main(String[] args) throws IOException {
		//parameter evaluation
		switch (args.length) {
		case 0:
			System.out.println(helpText);
			break;
		default:
			if(args[0].equals("debug"))
				DEBUG_MODE = true;
			break;
		}

		//select a file
		JFileChooser jfc = new JFileChooser(".\\tests\\words");
		jfc.setDialogTitle("Select the jPair-file you want to unpair...");
		
		if(jfc.showOpenDialog(null) != JFileChooser.APPROVE_OPTION)
			System.exit(0);
			
		File file = jfc.getSelectedFile();
		
		//open file and create Unpair-object, quit on error
		WordModel unpair = new WordModel(file, DEBUG_MODE);
		
		//initialize GUI window and show results
		WordFrame window = new WordFrame("WordNavigate: " + file.getAbsolutePath(), unpair);
		
		//show results
		window.setVisible(true);
	}
}
